/*<summary>
Created By : Preeti
Created On : 10/18/2008
Class Name : Consultant_Mapper
Used In    : 
------------------------------------------------------------------------
Modification Log  
------------------------------------------------------------------------
Created By        Modified By         Remarks                             
-----------       ------------        ----------------------------------
                                                                          
------------------------------------------------------------------------
</summary>*/


using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Utils;

namespace AdminController
{
    public class Consultant_Mapper
    {
        public bool Load_Consultant_DATA(string ConsultantID, Consultant objConsultant)
        {
            if (!(objConsultant == null))
            {
                ezUtilsAdapter DBL = new ezUtilsAdapter();
                int ResultVal;
                bool bresult;
                string LastName;
                string FirstName;
                string FullName;
                string Address;
                string City;
                string State;
                string ZipCode;
                string MobilePhone;
                string OfficePhone;
                string HomePhone;
                string EmailAddress;
                string EmergencyContactName;
                string EmergencyContactPhone;
                string Specialization;
                string Remarks;
                double Fees;

                LastName = objConsultant.LastName;
                FirstName = objConsultant.FirstName;
                FullName = objConsultant.FullName;
                Address = objConsultant.Address;
                City = objConsultant.City;
                State = objConsultant.State;
                ZipCode = objConsultant.ZipCode;
                MobilePhone = objConsultant.MobilePhone;
                OfficePhone = objConsultant.OfficePhone;
                HomePhone = objConsultant.HomePhone;
                EmailAddress = objConsultant.EmailAddress;
                EmergencyContactName = objConsultant.EmergencyContactName;
                EmergencyContactPhone = objConsultant.EmergencyContactPhone;
                Specialization = objConsultant.Specialization;
                Remarks = objConsultant.Remarks;
                Fees = objConsultant.Fees;

                try
                {
                    ResultVal = DBL.RunSPReturnInteger("SP_SetConsultant",
                    new SqlParameter("@vchConsultantID", ConsultantID),
                   new SqlParameter("@vchLastName", LastName),
                     new SqlParameter("@vchFirstName", FirstName),
                     new SqlParameter("@vchFullName", FullName),
                     new SqlParameter("@vchAddress", Address),
                     new SqlParameter("@vchCity", City),
                     new SqlParameter("@vchState", State),
                     new SqlParameter("@vchZipCode", ZipCode),
                     new SqlParameter("@vchMobilePhone", MobilePhone),
                     new SqlParameter("@vchOfficePhone", OfficePhone),
                     new SqlParameter("@vchHomePhone", HomePhone),
                     new SqlParameter("@vchEmailAddress", EmailAddress),
                     new SqlParameter("@vchEmergencyContactName", EmergencyContactName),
                     new SqlParameter("@vchEmergencyContactPhone", EmergencyContactPhone),
                     new SqlParameter("@vchSpecialization", Specialization),
                     new SqlParameter("@vchRemarks", Remarks),
                     new SqlParameter("@fltFees", Fees));
                    if (ResultVal == 0) { bresult = true; } else { bresult = false; } return bresult;
                }
                catch (SqlException ex)
                {
                    string errorMessage = string.Format(
                        "An Error Occurred While Loading the Consultant Information to the DB. Message: {0}", ex.Message);
                    //throw new MappingException(errorMessage, ex);}
                    return false;
                }
                finally
                {
                    DBL.Dispose();
                }
            }

            else { return false; }
        }

        public void Dispose()
        {
            this.Dispose(true);
            System.GC.SuppressFinalize(this);
        }

        private void Dispose(bool disposing)
        {
        }


    }
}